package io.ioThread;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedWriter;

public class Sender implements Runnable{


    private PipedWriter writer=new PipedWriter();
    @Override
    public void run() {
        BufferedReader br=null;
        try {
            br=new BufferedReader(new InputStreamReader(System.in));
            while(true){
                String s=br.readLine();
                if("$".equals(s)) return;
                writer.write(s);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(writer!=null){
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(br!=null){
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    public PipedWriter getWriter() {
        return writer;
    }

    public void setWriter(PipedWriter writer) {
        this.writer = writer;
    }
}
